home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / BlitzList / BlitzListFiles / BlitzC2P.lha / programming / blitz2 / programs / c2p040plus.ascii < prev    next >
Encoding:
Text File  |  1998-07-27  |  9.0 KB  |  510 lines

  1. WBStartup
  2. NoCli
  3.  
  4. ; 040/25 results:
  5.  
  6. ; 320x200 @46fps DoublePAL or 49.2fps PAL
  7. ; 320x256 @34.2fps DoublePAL or 37.9fps PAL
  8. ; 320x240 @37fps DoublePAL or 40.6fps PAL
  9.  
  10. ; 060/50 results:
  11.  
  12. ; 320x256 @50fps PAL
  13. ; 320x200 @66fps PAL
  14.  
  15. #c2pBPLX=320
  16. #c2pBPLY=256
  17. #c2pBPLSIZE=(#c2pBPLX*#c2pBPLY)/8
  18.  
  19. #scrwidth=#c2pBPLX
  20. #scrheight=#c2pBPLY
  21. #screensize=#scrwidth*#scrheight
  22.  
  23. ; Date: 20-Jan-1998     Mikael Kalms (Scout/C-Lous & more)
  24. ;         Email: mikael@kalms.org
  25. ;
  26. ; About:
  27. ;   1x1 8bpl cpu5 C2P for contigous bitplanes and no horizontal modulo
  28. ;
  29. ;   This routine is intended for use on all 68040 and 68060 based systems.
  30. ;   It is not designed to perform well on 68020-030.
  31. ;
  32. ;   This routine is released into the public domain. It may be freely used
  33. ;   for non-commercial as well as commercial purposes. A short notice via
  34. ;   email is always appreciated, though.
  35. ;
  36. ; Timings:
  37. ;   ~130% on (a1200 Blizzard) 040-25
  38. ;   Estimated to run at copyspeed on 040-40 and 060
  39. ;
  40. ; Features:
  41. ;   Performs CPU-only C2P conversion using rather state-of-the-art (as of
  42. ;   the creation date, anyway) techniques
  43. ;   Handles bitplanes creens of virtually any size (4GB)
  44. ;
  45. ; Restrictions:
  46. ;   Chunky-buffer must be an even multiple of 32 pixels wide
  47. ;   If incorrect/invalid parameters are specified, the routine will
  48. ;   most probably crash.
  49. ;
  50. ; c2p1x1_8_c5_040_smcinit   changes the bitplane-size &
  51. ;         chunkybuffer size/pos
  52. ; c2p1x1_8_c5_040_init      sets only the chunkybuffer size/pos
  53. ; c2p1x1_8_c5_040     performs the actual c2p conversion
  54. ;
  55.  
  56. Statement c2p040prefs{A.l,B.l,C.l,D.l}
  57.  
  58.   ;This routine DOES NOT WORK!
  59.  
  60.   ;A.l=d0=width.w
  61.   ;B.l=d1=height.w
  62.   ;C.w=d2=planarwidth.w
  63.   ;D.w=d3=planarheight.w
  64.  
  65.   MULU  d2,d3
  66.   MOVE.l  d3,d5
  67.  
  68. ; d0.w  chunkyx [chunky-pixels]
  69. ; d1.w  chunkyy [chunky-pixels]
  70. ; d3.w  scroffsy [screen-pixels]
  71. ; d5.l  bplsize [bytes] -- offset between one row in one bpl and the next bpl
  72.  
  73.   MOVEQ.l #0,d3 ; Y offset
  74.  
  75. _c2p1x1_8_c5_040_smcinit
  76. c2p1x1_8_c5_040_smcinit
  77.   MOVEM.l d3/a6,-(a7)
  78.   MULU.w  d0,d3
  79.   LSR.l #3,d3
  80.   MOVE.l  d3,c2p1x1_8_c5_040_scroffs
  81.   MULU.w  d0,d1
  82.   MOVE.l  d1,c2p1x1_8_c5_040_pixels
  83.   MOVE.l  d5,d0
  84.   LSL.l #3,d0
  85.   SUB.l d5,d0
  86.   MOVE.l  d0,c2p1x1_8_c5_040_smc1-4
  87.   ADDQ.l  #4,d0
  88.   MOVE.l  d0,c2p1x1_8_c5_040_smc5-4
  89.   MOVE.l  d5,d0
  90.   LSL.l #2,d0
  91.   MOVE.l  d0,c2p1x1_8_c5_040_smc2-4
  92.   MOVE.l  d0,c2p1x1_8_c5_040_smc4-4
  93.   MOVE.l  d0,c2p1x1_8_c5_040_smc6-4
  94.   MOVE.l  d0,c2p1x1_8_c5_040_smc8-4
  95.   MOVE.l  d0,c2p1x1_8_c5_040_smc10-4
  96.   MOVE.l  d0,c2p1x1_8_c5_040_smc12-4
  97.   SUB.l d5,d0
  98.   MOVE.l  d0,c2p1x1_8_c5_040_smc3-4
  99.   MOVE.l  d0,c2p1x1_8_c5_040_smc7-4
  100.   MOVE.l  d0,c2p1x1_8_c5_040_smc9-4
  101.   MOVE.l  d0,c2p1x1_8_c5_040_smc11-4
  102.   MOVE.l  execbase,a6
  103.   JSR _LVOCacheClearU(a6)
  104.   MOVEM.l (a7)+,d3/a6
  105. AsmExit
  106. End Statement
  107.  
  108. Statement c2p040init{A.l,B.l}
  109.  
  110.   ;A.l=d0=Width.w
  111.   ;B.l=d1=Height.w
  112.  
  113. ; d0.w  chunkyx [chunky-pixels]
  114. ; d1.w  chunkyy [chunky-pixels]
  115. ; d3.w  scroffsy [screen-pixels]
  116.  
  117.   MOVEQ.l #0,d3 ; Y offset
  118.  
  119. _c2p1x1_8_c5_040_init
  120. c2p1x1_8_c5_040_init
  121.   MULU.w  d0,d3
  122.   LSR.l #3,d3
  123.   MOVE.l  d3,c2p1x1_8_c5_040_scroffs
  124.   MULU.w  d0,d1
  125.   MOVE.l  d1,c2p1x1_8_c5_040_pixels
  126. AsmExit
  127. End Statement
  128.  
  129. Statement c2p040{A.l,B.l}
  130.  
  131.   MOVE.l  d0,a0 ; Chunky
  132.   MOVE.l  d1,a1 ; Planar
  133.  
  134. ; a0  c2pscreen
  135. ; a1  bitplanes
  136. #_LVOCacheClearU=-$27C
  137. #execbase=$4
  138. _c2p1x1_8_c5_040
  139. c2p1x1_8_c5_040
  140.   MOVEM.l a3-a6,-(a7)
  141.  
  142.   ADD.l #c2pBPLSIZE*7,a1
  143. c2p1x1_8_c5_040_smc1
  144.   ADD.l c2p1x1_8_c5_040_scroffs,a1
  145.  
  146.   MOVE.l  c2p1x1_8_c5_040_pixels,a2
  147.   MOVE.l  a2,d0 ; byPWest
  148.   TST.l d0 ;
  149.   BEQ _none
  150.   ADD.l a0,a2
  151.  
  152.   MOVE.l  (a0)+,d0
  153.   MOVE.l  (a0)+,d1
  154.   MOVE.l  (a0)+,d2
  155.   MOVE.l  (a0)+,d3
  156.   MOVE.l  (a0)+,d4
  157.   MOVE.l  (a0)+,d5
  158.   MOVE.l  (a0)+,a5
  159.   MOVE.l  (a0)+,a6
  160.  
  161.   SWAP  d4      ; Swap 16x4, part 1
  162.   SWAP  d5
  163.   EOR.w d0,d4
  164.   EOR.w d1,d5
  165.   EOR.w d4,d0
  166.   EOR.w d5,d1
  167.   EOR.w d0,d4
  168.   EOR.w d1,d5
  169.   SWAP  d4
  170.   SWAP  d5
  171.  
  172.   MOVE.l  d4,d6     ; Swap 2x4, part 1
  173.   MOVE.l  d5,d7
  174.   LSR.l #2,d6
  175.   LSR.l #2,d7
  176.   EOR.l d0,d6
  177.   EOR.l d1,d7
  178.   AND.l #$33333333,d6
  179.   AND.l #$33333333,d7
  180.   EOR.l d6,d0
  181.   EOR.l d7,d1
  182.   LSL.l #2,d6
  183.   LSL.l #2,d7
  184.   EOR.l d6,d4
  185.   EOR.l d7,d5
  186.  
  187.   EXG d4,a5
  188.   EXG d5,a6
  189.  
  190.   SWAP  d4      ; Swap 16x4, part 2
  191.   SWAP  d5
  192.   EOR.w d2,d4
  193.   EOR.w d3,d5
  194.   EOR.w d4,d2
  195.   EOR.w d5,d3
  196.   EOR.w d2,d4
  197.   EOR.w d3,d5
  198.   SWAP  d4
  199.   SWAP  d5
  200.  
  201.   MOVE.l  d4,d6     ; Swap 2x4, part 1
  202.   MOVE.l  d5,d7
  203.   LSR.l #2,d6
  204.   LSR.l #2,d7
  205.   EOR.l d2,d6
  206.   EOR.l d3,d7
  207.   AND.l #$33333333,d6
  208.   AND.l #$33333333,d7
  209.   EOR.l d6,d2
  210.   EOR.l d7,d3
  211.   LSL.l #2,d6
  212.   LSL.l #2,d7
  213.   EOR.l d6,d4
  214.   EOR.l d7,d5
  215.  
  216.   MOVE.l  d1,d6     ; Swap 4x1, part 1
  217.   MOVE.l  d3,d7
  218.   LSR.l #4,d6
  219.   LSR.l #4,d7
  220.   EOR.l d0,d6
  221.   EOR.l d2,d7
  222.   AND.l #$0f0f0f0f,d6
  223.   AND.l #$0f0f0f0f,d7
  224.   EOR.l d6,d0
  225.   EOR.l d7,d2
  226.   LSL.l #4,d6
  227.   LSL.l #4,d7
  228.   EOR.l d6,d1
  229.   EOR.l d7,d3
  230.  
  231.   BRA _start
  232.  
  233.   Even8
  234.   Even8
  235. _x
  236.   MOVE.l  (a0)+,d0
  237.   MOVE.l  (a0)+,d1
  238.   MOVE.l  (a0)+,d2
  239.   MOVE.l  (a0)+,d3
  240.   MOVE.l  (a0)+,d4
  241.   MOVE.l  (a0)+,d5
  242.   MOVE.l  (a0)+,a5
  243.   MOVE.l  (a0)+,a6
  244.  
  245.   MOVE.l  d6,(a1)
  246.   SUB.l #c2pBPLSIZE*4,a1
  247. c2p1x1_8_c5_040_smc2
  248.  
  249.   SWAP  d4      ; Swap 16x4, part 1
  250.   SWAP  d5
  251.   EOR.w d0,d4
  252.   EOR.w d1,d5
  253.   EOR.w d4,d0
  254.   EOR.w d5,d1
  255.   EOR.w d0,d4
  256.   EOR.w d1,d5
  257.   SWAP  d4
  258.   SWAP  d5
  259.  
  260.   MOVE.l  d7,(a1)
  261.   ADD.l #c2pBPLSIZE*3,a1
  262. c2p1x1_8_c5_040_smc3
  263.  
  264.   MOVE.l  d4,d6     ; Swap 2x4, part 1
  265.   MOVE.l  d5,d7
  266.   LSR.l #2,d6
  267.   LSR.l #2,d7
  268.   EOR.l d0,d6
  269.   EOR.l d1,d7
  270.   AND.l #$33333333,d6
  271.   AND.l #$33333333,d7
  272.   EOR.l d6,d0
  273.   EOR.l d7,d1
  274.   LSL.l #2,d6
  275.   LSL.l #2,d7
  276.   EOR.l d6,d4
  277.   EOR.l d7,d5
  278.  
  279.   EXG d4,a5
  280.   EXG d5,a6
  281.  
  282.   SWAP  d4      ; Swap 16x4, part 2
  283.   SWAP  d5
  284.   EOR.w d2,d4
  285.   EOR.w d3,d5
  286.   EOR.w d4,d2
  287.   EOR.w d5,d3
  288.   EOR.w d2,d4
  289.   EOR.w d3,d5
  290.   SWAP  d4
  291.   SWAP  d5
  292.  
  293.   MOVE.l  a3,(a1)
  294.   SUB.l #c2pBPLSIZE*4,a1
  295. c2p1x1_8_c5_040_smc4
  296.  
  297.   MOVE.l  d4,d6     ; Swap 2x4, part 1
  298.   MOVE.l  d5,d7
  299.   LSR.l #2,d6
  300.   LSR.l #2,d7
  301.   EOR.l d2,d6
  302.   EOR.l d3,d7
  303.   AND.l #$33333333,d6
  304.   AND.l #$33333333,d7
  305.   EOR.l d6,d2
  306.   EOR.l d7,d3
  307.   LSL.l #2,d6
  308.   LSL.l #2,d7
  309.   EOR.l d6,d4
  310.   EOR.l d7,d5
  311.  
  312.   MOVE.l  d1,d6     ; Swap 4x1, part 1
  313.   MOVE.l  d3,d7
  314.   LSR.l #4,d6
  315.   LSR.l #4,d7
  316.   EOR.l d0,d6
  317.   EOR.l d2,d7
  318.   AND.l #$0f0f0f0f,d6
  319.   AND.l #$0f0f0f0f,d7
  320.   EOR.l d6,d0
  321.   EOR.l d7,d2
  322.   LSL.l #4,d6
  323.   LSL.l #4,d7
  324.   EOR.l d6,d1
  325.   EOR.l d7,d3
  326.  
  327.   MOVE.l  a4,(a1)
  328.   ADD.l #c2pBPLSIZE*7+4,a1
  329. c2p1x1_8_c5_040_smc5
  330.  
  331. _start
  332.   MOVE.l  d2,d6     ; Swap 8x2, part 1
  333.   MOVE.l  d3,d7
  334.   LSR.l #8,d6
  335.   LSR.l #8,d7
  336.   EOR.l d0,d6
  337.   EOR.l d1,d7
  338.   AND.l #$00ff00ff,d6
  339.   AND.l #$00ff00ff,d7
  340.   EOR.l d6,d0
  341.   EOR.l d7,d1
  342.   LSL.l #8,d6
  343.   LSL.l #8,d7
  344.   EOR.l d6,d2
  345.   EOR.l d7,d3
  346.  
  347.   MOVE.l  d2,d6     ; Swap 1x2, part 1
  348.   MOVE.l  d3,d7
  349.   LSR.l #1,d6
  350.   LSR.l #1,d7
  351.   EOR.l d0,d6
  352.   EOR.l d1,d7
  353.   AND.l #$55555555,d6
  354.   AND.l #$55555555,d7
  355.   EOR.l d6,d0
  356.   EOR.l d7,d1
  357.   LSL.l #1,d6
  358.   LSL.l #1,d7
  359.   EOR.l d6,d2
  360.   EOR.l d7,d3
  361.  
  362.   MOVE.l  d0,(a1)
  363.   SUB.l #c2pBPLSIZE*4,a1
  364. c2p1x1_8_c5_040_smc6
  365.  
  366.   MOVE.l  a5,d6
  367.   MOVE.l  a6,d7
  368.   MOVE.l  d2,a3
  369.   MOVE.l  d3,a4
  370.  
  371.   MOVE.l  d5,d2     ; Swap 4x1, part 2
  372.   MOVE.l  d7,d3
  373.   LSR.l #4,d2
  374.   LSR.l #4,d3
  375.   EOR.l d4,d2
  376.   EOR.l d6,d3
  377.   AND.l #$0f0f0f0f,d2
  378.   AND.l #$0f0f0f0f,d3
  379.   EOR.l d2,d4
  380.   EOR.l d3,d6
  381.  
  382.   MOVE.l  d1,(a1)
  383.   ADD.l #c2pBPLSIZE*3,a1
  384. c2p1x1_8_c5_040_smc7
  385.  
  386.   LSL.l #4,d2
  387.   LSL.l #4,d3
  388.   EOR.l d2,d5
  389.   EOR.l d3,d7
  390.  
  391.   MOVE.l  d4,d2     ; Swap 8x2, part 2
  392.   MOVE.l  d5,d3
  393.   LSR.l #8,d2
  394.   LSR.l #8,d3
  395.   EOR.l d6,d2
  396.   EOR.l d7,d3
  397.   AND.l #$00ff00ff,d2
  398.   AND.l #$00ff00ff,d3
  399.   EOR.l d2,d6
  400.   EOR.l d3,d7
  401.  
  402.   MOVE.l  a3,(a1)
  403.   SUB.l #c2pBPLSIZE*4,a1
  404. c2p1x1_8_c5_040_smc8
  405.  
  406.   LSL.l #8,d2
  407.   LSL.l #8,d3
  408.   EOR.l d2,d4
  409.   EOR.l d3,d5
  410.  
  411.   MOVE.l  d4,d2     ; Swap 1x2, part 2
  412.   MOVE.l  d5,d3
  413.   LSR.l #1,d2
  414.   LSR.l #1,d3
  415.   EOR.l d6,d2
  416.   EOR.l d7,d3
  417.   AND.l #$55555555,d2
  418.   AND.l #$55555555,d3
  419.  
  420.   MOVE.l  a4,(a1)
  421.   ADD.l #c2pBPLSIZE*3,a1
  422. c2p1x1_8_c5_040_smc9
  423.  
  424.   EOR.l d2,d6
  425.   EOR.l d3,d7
  426.   LSL.l #1,d2
  427.   LSL.l #1,d3
  428.   EOR.l d2,d4
  429.   EOR.l d3,d5
  430.  
  431.   MOVE.l  d4,a3
  432.   MOVE.l  d5,a4
  433.  
  434.   CMP.l a0,a2
  435.   BNE _x
  436.  
  437.   MOVE.l  d6,(a1)
  438.   SUB.l #c2pBPLSIZE*4,a1
  439. c2p1x1_8_c5_040_smc10
  440.   MOVE.l  d7,(a1)
  441.   ADD.l #c2pBPLSIZE*3,a1
  442. c2p1x1_8_c5_040_smc11
  443.   MOVE.l  a3,(a1)
  444.   SUB.l #c2pBPLSIZE*4,a1
  445. c2p1x1_8_c5_040_smc12
  446.   MOVE.l  a4,(a1)
  447.  
  448. _none: MOVEM.l (a7)+,a3-a6
  449. AsmExit
  450.  
  451. Even4
  452. c2p1x1_8_c5_040_scroffs: Dc.l 0
  453. c2p1x1_8_c5_040_pixels: Dc.l 0
  454. End Statement
  455.  
  456.  
  457.  
  458.  
  459.  
  460. .blitzprogram
  461. ; Setup
  462. InitBank 0,(#scrwidth*#scrheight)+1000,2|65536 ; Chipram planar buffer
  463. CludgeBitMap 0,#scrwidth,#scrheight,8,Bank(0)
  464. InitPalette 0,256
  465. For c=0 To 255
  466.   AGAPalRGB 0,c,Rnd(c),Rnd(c),Rnd(c)
  467. Next c
  468. AGAPalRGB 0,0,0,0,0
  469. Screen 0,0,0,#scrwidth,#scrheight,8,0,"c2p test",0,0,0
  470. Use Palette 0
  471. VWait 50
  472. baseaddress1.l=AllocMem(#scrwidth*#scrheight,$10000) ; Fastram chunky buffer
  473.  
  474. ; Put something into the chunky buffer so we can see it working
  475. GetReg a0,baseaddress1
  476. MOVE.l  #0,d0
  477. MOVE.l  #screensize-1,d1
  478. cloop
  479.   MOVE.b  d0,(a0)+
  480.   ADDQ.l  #1,d0
  481.   SUBQ.l  #1,d1
  482.   TST.l   d1
  483.   BLT     done
  484.   BRA     cloop
  485. done
  486.  
  487. ; Do the c2p test
  488. c2p040init{#scrwidth,#scrheight}
  489. VWait 20
  490. Forbid_
  491. VWait
  492. ResetTimer
  493. For time=1 To 800
  494.   c2p040{baseaddress1,Bank(0)} ; Convert chunky to planar
  495. Next time
  496. t=Ticks
  497. VWait 2 : Permit_
  498. VWait 20
  499. FindScreen 0
  500. Window 0,0,11,640,100,0,"Test results for c2p",0,0
  501. WindowOutput 0
  502. NPrint "Routine performed @ ",50/(t/800),"fps - ",t," ticks"
  503. NPrint " "
  504. NPrint "Press mousebutton..."
  505. Free Screen 0
  506. MouseWait
  507. Free Window 0
  508. End
  509.  
  510.